package org.yankun.exam4j.common.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

public class TimeUtils {	
	public static final List<String> getTimeString(int time){
		List<String> times = new LinkedList<String>();
		
		if(time < 10){
			for(int i=0;i<time;i++){
				times.add("0"+i);
			}
			
		}else{
			
			for(int i=0;i<10;i++){
				times.add("0"+i);
			}
			
			for(int i=10;i<time;i++){
				times.add(i+"");
			}
		}
		return times;
	}
	
	public static final Date[] StringToDate(String[] num) throws ParseException{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Date[] f = new Date[num.length];
		for(int i=0;i<num.length;i++){
			f[i] = sdf.parse(num[i]);
		}
		return f;
	}
	
	public static final Date StringToDate(String num) throws ParseException{
		if(null!=num&&""!=num){
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			Date date = new Date();
			date = sdf.parse(num);
			return date;
		}
		return null;
	}
	
	public static final Date StringToDateTime(String num) throws ParseException{
		if(null!=num&&""!=num){
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Date date = new Date();
			date = sdf.parse(num);
			return date;
		}
		return null;
	}
	
}
